import requests
from bs4 import BeautifulSoup
from Wappalyzer import Wappalyzer, WebPage
import sys

def get_headers(url):
    try:
        response = requests.get(url, timeout=10)
        headers = response.headers
        return headers
    except requests.RequestException as e:
        print(f"Error fetching headers: {e}")
        return {}

def get_server_info(headers):
    server = headers.get('Server', 'Unknown')
    return server

def get_wappalyzer_info(url):
    wappalyzer = Wappalyzer.latest()
    try:
        webpage = WebPage.new_from_url(url)
        technologies = wappalyzer.analyze(webpage)
        return technologies
    except Exception as e:
        print(f"Error using Wappalyzer: {e}")
        return []

def print_info(url):
    headers = get_headers(url)
    server_info = get_server_info(headers)
    wappalyzer_info = get_wappalyzer_info(url)

    print(f"Website: {url}")
    print(f"Server: {server_info}")
    print("Technologies detected:")
    for tech in wappalyzer_info:
        print(f"  - {tech}")

if __name__ == "__main__":
    if len(sys.argv) != 2:
        print("Usage: python3 website_fingerprint.py <url>")
        sys.exit(1)

    url = sys.argv[1]
    print_info(url)
    
# pip install requests beautifulsoup4 Wappalyzer
# sansjtw